﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lcmyjobs.Web.users
{
    public partial class PostEmail : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Title = string.Format("个人管理中心—我的工作：外发简历   {0}", Application["webname"].ToString());

                if (Session["user_id"] == null)
                {
                    Response.Redirect("userlogin.html");
                }
                else
                {
                    int id = int.Parse(Session["user_id"].ToString());
                    this.lblName.Text = Session["user_name"].ToString();
                    txtBody.Text = "尊贵的            ：\r\n我是" + this.lblName.Text + "，我对您仰慕已久；呈上我的简历，殷盼加入贵单位。\r\n此致敬礼！";
                }
            }

        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string email = txtEmail.Text;
                string title = txtTitle.Text;
                string body = txtBody.Text;
                try
                {
                    lcmyjobs.Model.email em = new Model.email();
                    em.port = int.Parse(myPublic.GetConfig("emailHostPort"));
                    em.sendEmailAdd = myPublic.GetConfig("sendEmailAdd");
                    em.sendEmailPwd = myPublic.GetConfig("sendEmailPwd");
                    em.serverhost = myPublic.GetConfig("emailHost");
                    em.title = title;
                    em.receiveEmailAdd = email;
                    em.content = body;
                    
                    lcmyjobs.BLL.SendEmail se = new BLL.SendEmail(em);
                    se.Send();
                    //myPublic.sendMail(email, title, body);                    
                    Maticsoft.Common.MessageBox.Show(this, "发送成功！");
                }
                catch (Exception ex)
                {

                    Maticsoft.Common.MessageBox.Show(this, "发送失败！");
                }
            }
        }
    }
}